import Vue from 'vue'
import './plugins/axios'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'


Vue.config.productionTip = false

//钩子函数，访问路由前调用
router.beforeEach((to, from, next) => {
      //路由需要认证
      if (to.meta.requireAuth) {
        //判断store里是否有token
        if (store.state.token) {
          next()
        } else {
          next({
            path: '/',
            query: { redirect: to.fullPath }
          })
        }
      } else {
        next()
      }
    }
)

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
